home *** CD-ROM | disk | FTP | other *** search
/ Mac100% 1998 November / MAC100-1998-11.ISO.7z / MAC100-1998-11.ISO / スクリーンセーバーファクトリー / DarkSide of the Mac 5.0.2 / SampleFaders / Fader.h < prev    next >
Text File  |  1997-03-19  |  7KB  |  193 lines

  1. #ifndef __FADER__
  2. #define __FADER__
  3. /*
  4.     DarkSide - a 7.0 dependant, system clean expandable screen saver.
  5.     
  6.     copyright ゥハ1990-1997 by Tom Dowdy
  7.     All rights reserved.
  8.     
  9.     This header file defines the interface between DarkSide and one of
  10.     its faders.
  11.  
  12. */
  13.  
  14. #ifndef __TYPES__
  15.     #include <Types.h>
  16. #endif
  17. #ifndef __OSUTILS__
  18.     #include <OSUtils.h>
  19. #endif
  20. #ifndef __QUICKDRAW__
  21.     #include <QuickDraw.h>
  22. #endif
  23. #ifndef __SOUND__
  24.     #include <Sound.h>
  25. #endif
  26. #ifndef __DIALOGS__
  27.     #include <Dialogs.h>
  28. #endif
  29.  
  30. #if defined(powerc) || defined (__powerc)
  31. #pragma options align=mac68k
  32. #endif
  33.  
  34. // errors
  35. #define darkSideWrongVersion    1
  36. #define darkSideNoGX            2
  37. #define darkSideNoPPC            3
  38. #define darkSideNoBitDepth        4
  39.  
  40. // entry points
  41. #define    preflightFader        0
  42. #define initializeFader        1
  43. #define idleFader            2
  44. #define disposeFader        3
  45. #define updateFader            4
  46. #define hitFader            5
  47.  
  48. // info about a screen
  49. typedef struct
  50.     {
  51.     Rect        bounds;                    // bounds of that screen within our window
  52.     Boolean        isColor;                // color or bw/gray
  53.     short        depth;                    // depth in pixels
  54.     GDHandle    theDevice;                // device that goes with that screen
  55.     
  56.     short        originalDepth;            // depth before any changes
  57.     short        originalFlags;            // original device flags
  58.     short        whichFlagsChanged;        // which flags we changed
  59.     
  60.     Handle        screenGamma;            // copy of the screen's original gamma table
  61.     short        brightness;                // current monitor brightness (0-255)
  62.     short        newBrightness;            // new monitor brightness to set (0-255)
  63.     } ScreenInfo, *ScreenInfoPtr;
  64.         
  65. // storage for the user's settings
  66. #define numShorts    20
  67. #define numStrings    4
  68. typedef struct
  69.     {
  70.     short                theShorts[numShorts];
  71.     Str255                theStrings[numStrings];
  72.     } SettingsBlock, *SettingsPtr;
  73.  
  74. // currently supported options
  75. #define keyAndMouseUnfade        0x0001    // 0 if fader is allowing keystrokes/mouse motion
  76. #define faderRequestsUnfade        0x0002    // 1 if fader wishes to cause an unfade
  77. #define faderRequestsNoWindow     0x0004    // 1 if fader wishes no fade window
  78. #define ignoreModifierKeys        0x0008    // 1 if fader wishes us to ignore modifiers
  79.  
  80. // info about the machine
  81. typedef struct
  82.     {
  83.     SysEnvRec        theEnvirons;        // info about the machine
  84.     WindowPtr        fadeWindow;            // where the fade is taking place
  85.     Ptr                applicationQD;        // app QuickDraw globals
  86.     Ptr                applicationA5;        // A5 for the application
  87.     long            faderOptions;        // options for the fader to give to DarkSide
  88.     SettingsPtr        faderSettings;        // user's settings for the fader
  89.     DialogPtr        settingsDialog;        // dialog with the settings
  90.     short            soundVolume;        // volume set by the user
  91.     SndChannelPtr    faderChannel;        // sound channel allocated for fader's use
  92.     Ptr                callbackLoader;        // segment loader for the callbacks
  93.     
  94.     short                numScreens;            // how many screens there are
  95.     ScreenInfo            theScreens[20];        // info about each screen
  96.     } MachineInfoRec, *MachineInfoPtr;
  97.     
  98.  
  99. // typedefs for the standard fader entry points    
  100. OSErr    PreflightFader(MachineInfoPtr machineInfo, long *minTicks, long *maxTicks);
  101. OSErr    InitializeFader(MachineInfoPtr machineInfo);
  102. OSErr    IdleFader(MachineInfoPtr machineInfo);
  103. OSErr    DisposeFader(MachineInfoPtr machineInfo);
  104. OSErr    UpdateFader(MachineInfoPtr machineInfo);
  105. OSErr    HitFader(MachineInfoPtr machineInfo, DialogPtr dPtr, short itemHit, short itemOffset);
  106.  
  107.  
  108. // Utilities
  109. Handle    BestNewHandle(Size theSize);
  110. RgnHandle    BestNewRgn();
  111. short Rnd(long max);
  112. void PlaceRectOnScreen(
  113.     MachineInfoPtr machineInfo,    // give info about the machine here
  114.     short width,                // width of rect, can be 0
  115.     short height,                // height of rect, can be 0
  116.     Rect * placedRect,            // Placed rect is returned here
  117.     Rect * margins,                // margins around screen, can be nil
  118.     short * whichScreen);        // screen index returned here, can be nil
  119.  
  120. // Utilities that utilize callbacks into DarkSide
  121.  
  122. // Calls to read and write additional data to/from the preferences file.  
  123. // WritePreferencesHandle disposes of the handle passed in
  124. // The handle returned by ReadPreferencesHandle should be disposed of by the caller
  125. OSErr    WritePreferencesHandle(MachineInfoPtr machineInfo, Handle h, ResType theType);
  126. OSErr    ReadPreferencesHandle(MachineInfoPtr machineInfo, Handle *h, ResType theType);
  127.  
  128. // play a 'snd ' with the specified resource ID through the sound channel created
  129. // by the 'Chnl' resource (if present).  Does nothing if a 'Chnl' is not present, or
  130. // if the user set the volume to zero
  131. OSErr    PlayResourceSnd(MachineInfoPtr machineInfo, short theID, Boolean async);
  132.  
  133. #ifdef powerc
  134.  
  135.     enum {
  136.         uppPreflightFaderProcInfo = kCStackBased
  137.              | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  138.              | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(MachineInfoPtr)))
  139.              | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  140.              | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Ptr))),
  141.  
  142.         uppInitializeFaderProcInfo = kCStackBased
  143.              | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  144.              | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(MachineInfoPtr))),
  145.  
  146.         uppIdleFaderProcInfo = kCStackBased
  147.              | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  148.              | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(MachineInfoPtr))),
  149.  
  150.         uppDisposeFaderProcInfo = kCStackBased
  151.              | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  152.              | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(MachineInfoPtr))),
  153.  
  154.         uppUpdateFaderProcInfo = kCStackBased
  155.              | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  156.              | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(MachineInfoPtr))),
  157.  
  158.         uppHitFaderProcInfo = kCStackBased
  159.              | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  160.              | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(MachineInfoPtr)))
  161.              | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DialogPtr)))
  162.              | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  163.              | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  164.  
  165.         uppCallbackInfo = kCStackBased 
  166.              | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  167.              | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  168.              | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  169.              | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))),
  170.              
  171.         callbackWritePreferencesHandle    = 1,
  172.         callbackReadPreferencesHandle    = 2,
  173.         callbackPlayResourceSnd    = 3
  174.     };
  175.  
  176. #endif
  177.  
  178. /* ------------------------------------------------------------------------------------    */
  179. /*    Useful macros for your fader                                                         */
  180. /* ------------------------------------------------------------------------------------    */
  181. #define TopLeft(aRect)    (* (Point *) &(aRect).top)
  182. #define BotRight(aRect)    (* (Point *) &(aRect).bottom)
  183. #define RectWidth(r) (short)((r)->right - (r)->left)
  184. #define RectHeight(r) (short)((r)->bottom - (r)->top)
  185.  
  186.  
  187. #if defined(powerc) || defined(__powerc)
  188. #pragma options align=reset
  189. #endif
  190.  
  191.  
  192. #endif
  193.